<span class="glyphicon glyphicon-map-marker" aria-hidden="true" style="position: absolute;top: 21px;">
    <span>系统</span> /
    <span>用户</span> /
    <span>密码修改</span>
</span>
<row>
    <div class="col-md-8 col-md-offset-2" style="margin-top: 37px;">
        <form class="form-horizontal">
            <div class="form-group">
                <label for="title" class="col-md-3 control-label">
                    <div class="text-center">用户密码</div>
                </label>
                <div class="col-md-9">
                    <input type="password" class="form-control" id="password"
                           name="password" placeholder="请输入用户密码">
                </div>
            </div>
            <div class="form-group">
                <label for="title" class="col-md-3 control-label">
                    <div class="text-center">用户新密码</div>
                </label>
                <div class="col-md-9">
                    <input type="password" class="form-control" id="passwords"
                           name="passwords" placeholder="请输入用户新密码">
                </div>
            </div>
            <div class="form-group">
                <label for="title" class="col-md-3 control-label">
                    <div class="text-center">用户确认密码</div>
                </label>
                <div class="col-md-9">
                    <input type="password" class="form-control" id="passwords1"
                           name="passwords1" placeholder="请输入用户确认密码">
                </div>
            </div>
            <div class="form-group save-btn">
                <button type="button" onclick="return getPasswords()" >保存</button>
                <button type="button" onclick="javascript:history.back(-1);return false;" style="background: red;">取消</button>
            </div>
        </form>
    </div>
</row>
<script type="text/javascript">
    function getPasswords() {
        var password = $("input[name='password']").val();
        var passwords = $("input[name='passwords']").val();
        var passwords1 = $("input[name='passwords1']").val();
        if(password == ""){
            layer.msg('请输入您的原密码...',
                {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
            return false;
        }
        if(passwords == ""){
            layer.msg('请输入您的新密码...',
                {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
            return false;
        }
        if(passwords1 == ""){
            layer.msg('请输入您的确认密码...',
                {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
            return false;
        }
        if(passwords != passwords1){
            layer.msg('您输入的新密码与确认密码不匹配...',
                {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
            return false;
        }
        var json = {"password":password,"passwords":passwords};
        $.ajax({
            type:'post',
            url: '__HTTP__/User/Password',
            data: json,
            success: function (res) {
                if(res.errMsg == "令牌失效"){
                    layer.msg('登录令牌失效,请重新登录',
                        {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
                    setTimeout('getLogin()',3000);
                    return;
                }
                if(res.errMsg == "密码错误"){
                    layer.msg('您输入的原密码不正确',
                        {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
                    return;
                }
                if(res.errMsg == "ok"){
                    layer.msg('密码修改成功，请重新登录',
                        {icon: 1,time: 2000,offset: 't',closeBtn: 0,shift:4});
                    setTimeout('getLogin()',3000);
                }
            }
        })
    }
</script> 